class Solution:
    def maximumSum(self, nums: List[int]) -> int:
        tmp = {}
        for i in enumerate(nums):
            key = sum(int(j) for j in str(i[1]))
            if key not in tmp:
                tmp[key] = [i]
            else :
                tmp[key].append(i)
        for key in tmp:
            tmp[key].sort(key=lambda x: x[1], reverse=True)
        curr_max = -1
        for j in tmp:
            if len(tmp[j]) > 1:
                curr_max = max(curr_max, tmp[j][0][1] + tmp[j][1][1])
        return curr_max
